<?php


use Vier\EthTool\Credential;
use Vier\EthTool\TokenBase;
use Web3\Utils;

include 'token20.php';

$sysconf = null;//TODO:
TokenBase::setDefault([
	'NetworkId'=>$sysconf['NetworkId'],
	'ChainApiUrl'=>$sysconf['ChainApiUrl'],
	'ManagerKey'=>$sysconf['ManagerKey'],
]);
$t20 = new Token20([
		'addr'=>$sysconf['ERC20Addr'],
		'abi'=>$sysconf['ERC20Abi'],
	]);


$txhash = $t20->transfer('0x0000...','0.01','ether');

$txid = db::t('order')->insert([
	'tx_hash'=>$txhash,
	'create_at'=>$time,
]);

if($t20->waitForReceipt($txhash)){
	db::t('order')->update($txid,['is_sync'=>1]);

	return [true,$txhash];
}